home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 January / Disc 3 / Amethyst.iso / live / usr / lib / rpm-3.0.6 / find-requires.perl < prev    next >
Encoding:
Text File  |  2001-04-06  |  1.5 KB  |  51 lines

  1. #!/bin/sh
  2.  
  3. # note this works for both a.out and ELF executables
  4. # it also auto-generates requirment lines for shell scripts
  5.  
  6. ulimit -c 0
  7.  
  8. filelist=`sed "s/['\"]/\\\&/g"`
  9. exelist=`echo $filelist | xargs -r file | fgrep executable | cut -d: -f1 `
  10. scriptlist=`echo $filelist | xargs -r file | egrep ":.* (commands|script) " | cut -d: -f1 `
  11. liblist=`echo $filelist | xargs -r file | grep "shared object" | cut -d : -f1 `
  12.  
  13. for f in $exelist; do
  14.     if [ -x $f ]; then
  15.     ldd $f | awk '/=>/ { print $1 }'
  16.     fi
  17. done | sort -u | sed "s/['\"]/\\\&/g" | xargs -r -n 1 basename | grep -v 'libNoVersion.so' | grep -v '4[um]lib.so' | sort -u
  18.  
  19. for f in $liblist; do
  20.     ldd $f | awk '/=>/ { print $1 }'
  21. done | sort -u | sed "s/['\"]/\\\&/g" | xargs -r -n 1 basename | grep -v 'libNoVersion.so' | grep -v '4[um]lib.so' | sort -u
  22.  
  23. perllist=
  24. for f in $scriptlist; do
  25.     [ -x $f ] || continue
  26.     interp=`head -1 $f | sed -e 's/^\#\![     ]*//' | cut -d" " -f1 `
  27.     case $interp in
  28.     */perl) perllist="$perllist $f" ;;
  29.     esac
  30.     echo $interp
  31. done | sort -u
  32.  
  33. for f in $liblist $exelist ; do
  34.     objdump -p $f | awk '
  35.     BEGIN { START=0; LIBNAME=""; }
  36.     /Version References:/ { START=1; }
  37.     /required from/ && (START==1) {
  38.         sub(/:/, "", $3);
  39.         LIBNAME=$3;
  40.     }
  41.     (START==1) && (LIBNAME!="") && ($4!="") { print LIBNAME "(" $4 ")"; }
  42.     /^$/ { START=0; }
  43.     '
  44. done | sort -u
  45.  
  46. #
  47. # Generate perl module dependencies, if any.
  48. set -x
  49. [ -x /usr/lib/rpm/perl.req -a -n "$perllist" ] && \
  50.     echo $perllist | tr [:blank:] \\n | /usr/lib/rpm/perl.req | sort -u
  51.